package com.tianquan.miracle.listener.refreshed;/**
 * @author starsea
 * @date 2024-10-12 下午6:45
 */

import com.tianquan.miracle.listener.core.EventListener;

/**
 * @BelongsProject: uploaddemo
 * @BelongsPackage: com.tianquan.miracle.listener.refreshed
 * @Author: tianquan
 * @CreateTime: 2024-10-12  18:45
 * @Description: 监听容器刷新完事件
 * @Version: 1.0
 */
public class ContextRefreshedEventListener implements EventListener<ContextRefreshedEvent> {

    private boolean use = true;

    @Override
    public void onEvent(ContextRefreshedEvent event) {
        if (!use) return;
        long startTime = event.getStartTime();
        long endTime = event.getEndTime();
        // 时间戳转秒
        double time = ((endTime - startTime) * 0.001);
        System.out.println("容器启动时间：" + time + "秒");
        use = false;
    }

}


